<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script type="module">
    import { request } from "../js/ajax.js";

    /* var p1 = request({
        type: "get",
        url: "../data/1.txt",
    })
    var p2 = request({
        type: "get",
        url: "../data/2.txt",
    })
    var p3 = request({
        type: "get",
        url: "../data/3.txt",
    })

    var str = "";
    p1.then((txt) => {
        console.log("fulfilled", txt);
        str += txt;
        return p2;
    }).then((txt) => {
        console.log("fulfilled", txt);
        str += txt;
        return p3;
    }).then((txt) => {
        console.log("fulfilled", txt);
        str += txt;
        return str;
    }).then(txt => {
        console.log("fulfilled", txt);

    }).catch(err => {
        console.log("rejected", err);
    }) */


    function readText(url) {
        return request({ type: "get", url: url });
    }

    var p1 = readText("../data/1.txt");
    var p2 = readText("../data/2.txt");
    var p3 = readText("../data/3.txt");

    var str = "";
    p1.then((txt) => {
        console.log("fulfilled", txt);
        str += txt;
        return p2;
    }).then((txt) => {
        console.log("fulfilled", txt);
        str += txt;
        return p3;
    }).then((txt) => {
        console.log("fulfilled", txt);
        str += txt;
        return str;
    }).then(txt => {
        console.log("fulfilled", txt);

    }).catch(err => {
        console.log("rejected", err);
    })





</script>

</html>